/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: PduR.c
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: PDUR
*
*******************************************************************************/


/** HEADER FILES **/
#include "PduRCfg.h"
#include "PduRCanTpCfg.h"
#include "PduRCanIfCfg.h"
#include "PduRDcmCfg.h"
#include "PduRComCfg.h"


/** MACRO DEFINITION **/


/** TYPEDEF DEFINITION **/
typedef struct
{
    PduR_DestPduType* destPduPtr; /* PduRDestPdu */
    PduR_SrcPduType* srcPduPtr; /* PduRSrcPdu */
    PduR_RoutingPathType* routingPathPtr; /* PduRRoutingPath */
}PduR_RoutingPathsType;


/** LOCAL DATA DEFINITION **/
const PduR_DestPduType PduR_DestPdu[PDURCONF_HANDLEID_MAX] = 
{
    /* pduDataProvision, destPduHandleId,                           confirmation, PduRDestPduRef  */
    {PDUR_DIRECT,        PduRConf_CanIfTxPdu_YT_Can1_0x101,         SET,          0x00}, /* PduRConf_PduHandleId_CanIf_Tx_YT_Can1_0x101 */
    {PDUR_DIRECT,        PduRConf_CanIfTxPdu_YT_Can2_0x102,         SET,          0x00}, /* PduRConf_PduHandleId_CanIf_Tx_YT_Can2_0x102 */
    {PDUR_DIRECT,        PduRConf_CanIfRxPdu_Other_Can1_201,        SET,          0x00}, /* PduRConf_PduHandleId_CanIf_Rx_Other_Can1_0x201 */
    {PDUR_DIRECT,        PduRConf_CanIfRxPdu_Other_Can2_202,        SET,          0x00}, /* PduRConf_PduHandleId_CanIf_Rx_Other_Can2_0x202 */
    {PDUR_DIRECT,        PduRConf_ComTxPdu_YT_Can1_0x101,           SET,          0x00}, /* PduRConf_PduHandleId_Com_Tx_YT_Can1_0x101 */
    {PDUR_DIRECT,        PduRConf_ComTxPdu_YT_Can2_0x102,           SET,          0x00}, /* PduRConf_PduHandleId_Com_Tx_YT_Can2_0x102 */
    {PDUR_DIRECT,        PduRConf_ComRxPdu_Other_Can1_201,          SET,          0x00}, /* PduRConf_PduHandleId_Com_Rx_Other_Can1_0x201 */
    {PDUR_DIRECT,        PduRConf_ComRxPdu_Other_Can2_202,          SET,          0x00}, /* PduRConf_PduHandleId_Com_Rx_Other_Can2_0x202 */
    {PDUR_DIRECT,        PduRConf_DcmTxPdu_DiagResponse,            SET,          0x00}, /* PduRConf_PduHandleId_Dcm_DiagResponse */
    {PDUR_DIRECT,        PduRConf_DcmRxPdu_DiagPhyRequest,          SET,          0x00}, /* PduRConf_PduHandleId_Dcm_DiagPhyRequest */
    {PDUR_DIRECT,        PduRConf_DcmRxPdu_DiagFuncRequest,         SET,          0x00}, /* PduRConf_PduHandleId_Dcm_DiagFuncRequest */
    {PDUR_DIRECT,        PduRConf_CanTpTxPdu_DiagResponse,          SET,          0x00}, /* PduRConf_PduHandleId_CanTp_DiagResponse */
    {PDUR_DIRECT,        PduRConf_CanTpRxPdu_DiagPhyRequest,        SET,          0x00}, /* PduRConf_PduHandleId_CanTp_DiagPhyRequest */
    {PDUR_DIRECT,        PduRConf_CanTpRxPdu_DiagFuncRequest,       SET,          0x00}  /* PduRConf_PduHandleId_CanTp_DiagFuncRequest */
};

const PduR_SrcPduType PduR_SrcPdu[PDURCONF_HANDLEID_MAX] = 
{
    /* BlockSize,  SourcePduHandleId,                                SrcPduUpTxConf, PduRSrcPduRef*/
    {0x08u,        PduRConf_PduHandleId_CanIf_Tx_YT_Can1_0x101,      SET,            0x00}, /* PduRConf_PduHandleId_CanIf_Tx_YT_Can1_0x101 */
    {0x08u,        PduRConf_PduHandleId_CanIf_Tx_YT_Can2_0x102,      SET,            0x00}, /* PduRConf_PduHandleId_CanIf_Tx_YT_Can2_0x102 */
    {0x08u,        PduRConf_PduHandleId_CanIf_Rx_Other_Can1_0x201,   SET,            0x00}, /* PduRConf_PduHandleId_CanIf_Rx_Other_Can1_0x201 */
    {0x08u,        PduRConf_PduHandleId_CanIf_Rx_Other_Can2_0x202,   SET,            0x00}, /* PduRConf_PduHandleId_CanIf_Rx_Other_Can2_0x202 */
    {0x08u,        PduRConf_PduHandleId_Com_Tx_YT_Can1_0x101,        SET,            0x00}, /* PduRConf_PduHandleId_Com_Tx_YT_Can1_0x101 */
    {0x08u,        PduRConf_PduHandleId_Com_Tx_YT_Can2_0x102,        SET,            0x00}, /* PduRConf_PduHandleId_Com_Tx_YT_Can2_0x102 */
    {0x08u,        PduRConf_PduHandleId_Com_Rx_Other_Can1_0x201,     SET,            0x00}, /* PduRConf_PduHandleId_Com_Rx_Other_Can1_0x201 */
    {0x08u,        PduRConf_PduHandleId_Com_Rx_Other_Can2_0x202,     SET,            0x00}, /* PduRConf_PduHandleId_Com_Rx_Other_Can2_0x202 */
    {0x08u,        PduRConf_PduHandleId_Dcm_DiagResponse,            SET,            0x00}, /* PduRConf_PduHandleId_Dcm_DiagResponse */
    {0x08u,        PduRConf_PduHandleId_Dcm_DiagPhyRequest,          SET,            0x00}, /* PduRConf_PduHandleId_Dcm_DiagPhyRequest */
    {0x08u,        PduRConf_PduHandleId_Dcm_DiagFuncRequest,         SET,            0x00}, /* PduRConf_PduHandleId_Dcm_DiagFuncRequest */
    {0x08u,        PduRConf_PduHandleId_CanTp_DiagResponse,          SET,            0x00}, /* PduRConf_PduHandleId_CanTp_DiagResponse */
    {0x08u,        PduRConf_PduHandleId_CanTp_DiagPhyRequest,        SET,            0x00}, /* PduRConf_PduHandleId_CanTp_DiagPhyRequest */
    {0x08u,        PduRConf_PduHandleId_CanTp_DiagFuncRequest,       SET,            0x00}  /* PduRConf_PduHandleId_CanTp_DiagFuncRequest */
};


const PduR_RoutingPathType PduR_RoutingPath[PDURCONF_ROUTINGPATH_MAX] = 
{
    /* PduRDestPduRRef,                                                                     PduRSrcPduRRef,                                                                        PduRQueueDepth, PduRTpThreshold, PduRDestBufferRef, RoutingMode */
    {(PduR_DestPduType*)&PduR_DestPdu[PduRConf_PduHandleId_Com_Rx_Other_Can1_0x201],        (PduR_SrcPduType*)&PduR_SrcPdu[PduRConf_PduHandleId_CanIf_Rx_Other_Can1_0x201],        0x00,           0x00,            NULL,              PDUR_ROUTINGMODE_CANIF_TO_COM}, /* CanIfCan1_To_ComCan1 */
    {(PduR_DestPduType*)&PduR_DestPdu[PduRConf_PduHandleId_Com_Rx_Other_Can2_0x202],        (PduR_SrcPduType*)&PduR_SrcPdu[PduRConf_PduHandleId_CanIf_Rx_Other_Can2_0x202],        0x00,           0x00,            NULL,              PDUR_ROUTINGMODE_CANIF_TO_COM}, /* CanifCan2_To_ComCan2 */
    {(PduR_DestPduType*)&PduR_DestPdu[PduRConf_PduHandleId_CanIf_Tx_YT_Can1_0x101],         (PduR_SrcPduType*)&PduR_SrcPdu[PduRConf_PduHandleId_Com_Tx_YT_Can1_0x101],             0x00,           0x00,            NULL,              PDUR_ROUTINGMODE_COM_TO_CANIF}, /* ComCan1_To_CanIfCan1 */
    {(PduR_DestPduType*)&PduR_DestPdu[PduRConf_PduHandleId_CanIf_Tx_YT_Can2_0x102],         (PduR_SrcPduType*)&PduR_SrcPdu[PduRConf_PduHandleId_Com_Tx_YT_Can2_0x102],             0x00,           0x00,            NULL,              PDUR_ROUTINGMODE_COM_TO_CANIF}, /* ComCan2_To_CanIfCan2 */
    {(PduR_DestPduType*)&PduR_DestPdu[PduRConf_PduHandleId_Dcm_DiagPhyRequest],             (PduR_SrcPduType*)&PduR_SrcPdu[PduRConf_PduHandleId_CanTp_DiagPhyRequest],             0x00,           0x00,            NULL,              PDUR_ROUTINGMODE_CANTP_TO_DCM}, /* CanTpDiagPhyRequest_To_DcmDiagPhyRequest */
    {(PduR_DestPduType*)&PduR_DestPdu[PduRConf_PduHandleId_CanTp_DiagResponse],             (PduR_SrcPduType*)&PduR_SrcPdu[PduRConf_PduHandleId_Dcm_DiagResponse],                 0x00,           0x00,            NULL,              PDUR_ROUTINGMODE_DCM_TO_CANTP}, /* DcmDiagResponse_To_CanIfDiagResponse */
};

PduR_RoutingPathsType PdurRoutingPathsCfg = 
{
    (PduR_DestPduType*)PduR_DestPdu,
    (PduR_SrcPduType*)PduR_SrcPdu,
    (PduR_RoutingPathType*)PduR_RoutingPath
};


const PduR_ProviderFctIfType PduR_ProviderFctIf[PDUR_ROUTINGMODE_MAX] = 
{
    /* CANIF_TO_COM */
    {
        NULL, /* LoCancelTransmitFct */
        NULL, /* LoTransmitFct */
        NULL, /* LoTpCancelReceiveFct */
        NULL, /* LoTpCancelTransmitFct */
        NULL, /* LoTpTransmitFct */
        Com_RxIndication, /* UpRxIndicationFct */
        NULL, /* UpTriggerTransmitFct */
        NULL, /* UpTxConfirmationFct */
        NULL, /* UpTpCopyRxDataFct */
        NULL, /* UpTpCopyTxDataFct */
        NULL, /* UpTpStartOfReceptionFct */
        NULL, /* UpTpTpRxIndicationFct */
        NULL, /* UpTpTpTxConfirmationFct */
    },
    /* CANTP_TO_DCM */
    {
        NULL, /* LoCancelTransmitFct */
        NULL, /* LoTransmitFct */
        NULL, /* LoTpCancelReceiveFct */
        NULL, /* LoTpCancelTransmitFct */
        NULL, /* LoTpTransmitFct */
        NULL, /* UpRxIndicationFct */
        NULL, /* UpTriggerTransmitFct */
        NULL, /* UpTxConfirmationFct */
        Dcm_CopyRxData, /* UpTpCopyRxDataFct */
        Dcm_CopyTxData, /* UpTpCopyTxDataFct */
        Dcm_StartOfReception, /* UpTpStartOfReceptionFct */
        NULL, /* UpTpTpRxIndicationFct */
        NULL, /* UpTpTpTxConfirmationFct */
    },
    /* COM_TO_CANIF */
    {
        NULL, /* LoCancelTransmitFct */
        CanIf_Transmit, /* LoTransmitFct */
        NULL, /* LoTpCancelReceiveFct */
        NULL, /* LoTpCancelTransmitFct */
        NULL, /* LoTpTransmitFct */
        NULL, /* UpRxIndicationFct */
        NULL, /* UpTriggerTransmitFct */
        NULL, /* UpTxConfirmationFct */
        NULL, /* UpTpCopyRxDataFct */
        NULL, /* UpTpCopyTxDataFct */
        NULL, /* UpTpStartOfReceptionFct */
        NULL, /* UpTpTpRxIndicationFct */
        NULL, /* UpTpTpTxConfirmationFct */
    },
    /* DCM_TO_CANTP */
    {
        NULL, /* LoCancelTransmitFct */
        CanTp_Transmit, /* LoTransmitFct */
        NULL, /* LoTpCancelReceiveFct */
        NULL, /* LoTpCancelTransmitFct */
        NULL, /* LoTpTransmitFct */
        NULL, /* UpRxIndicationFct */
        NULL, /* UpTriggerTransmitFct */
        NULL, /* UpTxConfirmationFct */
        NULL, /* UpTpCopyRxDataFct */
        NULL, /* UpTpCopyTxDataFct */
        NULL, /* UpTpStartOfReceptionFct */
        NULL, /* UpTpTpRxIndicationFct */
        NULL, /* UpTpTpTxConfirmationFct */
    }
};



